Class TreeCollection<TProps>

Assembly: redb.Core.dll

Typed version of collection for backward compatibility
Wrapper over polymorphic TreeCollection with type safety

public class TreeCollection<TProps> : IEnumerable<ITreeRedbObject<TProps>>, IEnumerable where TProps : class, new()

Inheritance

ObjectTreeCollection<TProps>

Implements

Properties

Count

Gets count of nodes in collection

public int Count { get; }

Leaves

Gets all leaf nodes (without children)

public IEnumerable<ITreeRedbObject<TProps>> Leaves { get; }

Orphans

Gets orphan nodes (whose parents haven't been added to collection)

public IEnumerable<ITreeRedbObject<TProps>> Orphans { get; }

Roots

Gets all root nodes (without parents)

public IEnumerable<ITreeRedbObject<TProps>> Roots { get; }

Methods

Add(ITreeRedbObject<TProps>)

Adds typed node to collection

public void Add(ITreeRedbObject<TProps> node)

AddRange(IEnumerable<ITreeRedbObject<TProps>>)

Adds range of typed nodes

public void AddRange(IEnumerable<ITreeRedbObject<TProps>> nodes)

Clear()

Clears collection

public void Clear()

Contains(long)

Checks if node with specified ID is contained

public bool Contains(long id)

FindById(long)

Finds typed node by ID

public ITreeRedbObject<TProps>? FindById(long id)

FindNodes(Func<ITreeRedbObject<TProps>, bool>)

Finds typed nodes by predicate

public IEnumerable<ITreeRedbObject<TProps>> FindNodes(Func<ITreeRedbObject<TProps>, bool> predicate)

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<ITreeRedbObject<TProps>> GetEnumerator()

GetFlattenedWithLevels()

Gets flattened list of all typed nodes with level indication

public IEnumerable<(ITreeRedbObject<TProps> Node, int Level)> GetFlattenedWithLevels()

GetStats()

Gets collection statistics

public TreeCollectionStats GetStats()

Remove(long)

Removes node from collection

public bool Remove(long id)

ValidateIntegrity()

Validates tree integrity

public IEnumerable<string> ValidateIntegrity()